﻿//#define debug
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessDll
{

    public class OperationLogic:AbsCommandLogic
    {
        public override void Run()
        {
            if (param.ContainsKey("command")) {
                WriteLog.WriteLogs("operation","接收到指令"+ param["command"]);
                switch (param["command"]) {
                    case "Y":
                        agree();
                        GlobalInfo.Instance.businessControl.taskInit(1);
                        break;
                    case "N":
                        refuse();
                        GlobalInfo.Instance.businessControl.taskInit(1);
                        break;
                    case "reset":
                        reset();
                        GlobalInfo.Instance.businessControl.taskInit(0);
                        break;
                    case "resetWT":
                        resetWt();
                        GlobalInfo.Instance.businessControl.taskInit(1);
                        break;
                    case "up":
                        up();
                        break;
                    case "down":
                        down();
                        break;
                    case "chgChnl":
                        chgChnl();
                        break;
                    default:
                        WriteLog.WriteLogs("commandline", "unknow command "+param["command"]);
                        break;
                }
            }
            //执行完命令就重置
            return;
        }
        public void agree() {


        }
        public void manulAgree()
        {

        }
        public void refuse() {

            
        }
        public void up() {

        }
        public void down() {

        }
        public void reset() {

        }
        public void resetWt() {

        }
        public void chgChnl()
        {

        }
        public Dictionary<String, String> chgStr2CommandParm(string _param) {
            String[] arrParam = _param.Split('&');
            Dictionary<String, String> mapParam = new Dictionary<string, string>();
            foreach (string one in arrParam){
                try
                {
                    String[] arrBody = one.Split('|');
                    mapParam.Add(arrBody[0], arrBody[1]);
                }
                catch (Exception ex)
                {
                    WriteLog.printException(ex);
                }
            }
            return mapParam;
        }
    }
}
